// JavaScript Document
var STLoaderHandlers = function(){
	this.onComplete;
}

// [[ 추상 클래스 ]]
var STTextLoader = function()
{
	
}
STTextLoader.READY_STATUS_RequestNotInitialized = 0;
STTextLoader.READY_STATUS_ServerConnectionEstablished = 1;
STTextLoader.READY_STATUS_RequestReceived = 2;
STTextLoader.READY_STATUS_ProcessingRequest = 3;
STTextLoader.READY_STATUS_RequestFinishedAndResponseIsReady = 4;

STTextLoader.STATUS_OK = 200;
STTextLoader.STATUS_PageNotFound = 404;


STTextLoader.prototype.getHttp = function()
{
	var http;
	if (window.XMLHttpRequest) {
       http = new XMLHttpRequest();
    } else {    // IE 5/6
       http = new ActiveXObject("Microsoft.XMLHTTP");
    }
	return http;
}
STTextLoader.prototype.load = function( method, url, async, handlers )
{
	var _http = this.getHttp();
	var _self = this;
	if( async == true )
	{
		_http.onreadystatechange=function()
		{
			if (this.readyState == STTextLoader.READY_STATUS_RequestFinishedAndResponseIsReady 
				&& this.status == STTextLoader.STATUS_OK)
			{
				_self.onComplete( this, handlers.onComplete );
			}
		}
	}
	_http.open( method, url, async );
	_http.send();
	if( async == false )
	{
		_self.onComplete( _http, handlers.onComplete );
	}
}
STTextLoader.prototype.onComplete = function( http, handler )
{
	handler.call( null, http.responseText );
}

// [[ XML 로더 ]]
var STXMLLoader = function()
{
	
}

// 상속 및 오버라이드
STXMLLoader.prototype = new STTextLoader();
STXMLLoader.prototype.onComplete = function( http, handler )
{
	if (window.DOMParser)
	{
		parser=new DOMParser();
		xmlDoc=parser.parseFromString( http.responseText,"text/xml");
	}
	else // Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.loadXML(http.responseText);
	}
	handler.call( null, xmlDoc );
}